package com.etc.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;

import org.springframework.web.context.ContextLoaderListener;

import com.etc.constants.WebConstants;

/**    
* @Title: WebContextLoaderListener.java  
* @Package com.etc.web  
* @Description: TODO 
* @author 黄宇    
* @date 2016年3月20日 下午5:51:22  
* @version V1.0    
*/
public class WebContextLoaderListener extends ContextLoaderListener{
	 /**
    * @param event
    *            event
    * @see org.springframework.web.context.ContextLoaderListener#contextInitialized(javax.servlet.ServletContextEvent)
    */
   public void contextInitialized(ServletContextEvent event)
   {
       super.contextInitialized(event);
       this.initApplication(event);
   }

   /**
    * 初始化application环境。<br/>
    * 
    * @param event
    *            event
    */
   private void initApplication(ServletContextEvent event)
   {
       if (null != event)
       {
           ServletContext sc = event.getServletContext();
           /* 初始化application级别的变量。 */
           sc.setAttribute("mainServer", WebConstants.MAIN_SERVER);
           sc.setAttribute("cssFileServer", WebConstants.CSS_FILE_SERVER);
           sc.setAttribute("jsFileServer", WebConstants.JS_FILE_SERVER);
           sc.setAttribute("imgServerLoad", WebConstants.IMG_FILE_SERVER_LOAD);
           sc.setAttribute("imgFileServer", WebConstants.IMG_FILE_SERVER);
       }
   }
}